<?php
error_reporting(E_ERROR | E_PARSE);
$servername = "localhost";
$username = "root";
$password = "wx25fbbc634ac5586b";
$dbname = "card";
$openid=$_GET["openid"];
// 创建连接
$conn = new mysqli($servername, $username, $password, $dbname);
$program_char = "utf8" ;
mysqli_set_charset( $conn , $program_char );
$sqls="select * from users where openid='$openid'";
$result = mysqli_query($conn,$sqls);//先从数据表中查询是否存在这样的openid
$temps=mysqli_fetch_array($result);
if($temps['openid']==null)
{
$sql="INSERT INTO `users` (`openid`, `phonenum`, `name`, `address`, `company`, `image`) VALUES ('$openid', '1', '1', '1', '1', '1');";
$results = mysqli_query($conn,$sql);
$temps=mysqli_fetch_all($results,MYSQLI_ASSOC);
}
else
{
  echo "已经存在";
}
?>